const fs = require('fs');
const path = require('path');

// 确保目标目录存在
function ensureDirectoryExistence(filePath) {
    const dirname = path.dirname(filePath);
    if (fs.existsSync(dirname)) {
        return true;
    }
    ensureDirectoryExistence(dirname);
    fs.mkdirSync(dirname);
}

// 复制HTML文件
const htmlFile = path.join(__dirname, 'src', 'renderer', 'index.html');
const targetHtmlFile = path.join(__dirname, 'dist', 'renderer', 'index.html');

ensureDirectoryExistence(targetHtmlFile);
fs.copyFileSync(htmlFile, targetHtmlFile);

// 复制编译后的JS文件
const jsFile = path.join(__dirname, 'dist', 'renderer', 'renderer.js');
const targetJsFile = path.join(__dirname, 'dist', 'renderer', 'renderer.js');

ensureDirectoryExistence(targetJsFile);
if (fs.existsSync(jsFile)) {
    fs.copyFileSync(jsFile, targetJsFile);
}

console.log('静态文件复制完成'); 